import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictServer extends UdpEchoServer{


    private HashMap<String,String>dict=new HashMap<>();


    public UdpDictServer(int port) throws SocketException {
        super(port);

        //初始化字典
        dict.put("小猫","cat");
        dict.put("小狗","dog");
        dict.put("小白兔","rabbit");
        dict.put("小鸭子","duck");
    }
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"未找到该词条");
    }


    public static void main(String[] args) throws IOException {
        UdpDictServer udpDictServer=new UdpDictServer(9090);
        udpDictServer.start();
    }
}
